package com.zx.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.zx.dao.StudentDao;
import com.zx.domain.Student;

import java.sql.SQLException;

public class StudentService {

    public static boolean addStudent(Student student) {

        try {
            return StudentDao.addStudent(student);
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
    }

    public static String printStudent() throws SQLException, JsonProcessingException {

        String s = StudentDao.printStudent();
        return s;
    }

    public static boolean deleteStudent(int id){

        try {
            return StudentDao.deleteStudent(id);
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
    }

    public static String queryStudent(int id){

        try {
            return StudentDao.queryStudent(id);
        } catch (SQLException | JsonProcessingException e) {
            e.printStackTrace();
            return null;
        }
    }
}
